Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/Goteo/Library/Forms/Model/ProjectCampaignForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,20 @@ public function createForm(): ProjectCampaignForm

$builder = $this->getBuilder();
$admin = Session::isAdmin();

$builder
->add('type', ChoiceType::class, [
'label' => 'project-campaign-type-label',
'data' => $project->type ?? $project->getConfig()->getType(),
'choices' => $this->projectTypeChoices(),
'required' => false,
'attr' => [
'pre-help' => Text::get('project-campaign-type-prehelp'),
]
]);

if ($admin) {
$builder
->add('type', ChoiceType::class, [
'label' => 'project-campaign-type-label',
'row_class' => 'extra',
'data' => $project->type ?? $project->getConfig()->getType(),
'choices' => $this->projectTypeChoices(),
'required' => false
])
->add('impact_calculator', BooleanType::class, [
'label' => 'project-campaign-impact-calculator',
'row_class' => 'extra',
Expand Down Expand Up @@ -128,7 +133,8 @@ private function projectTypeChoices(): array
];
}

public function save(FormInterface $form = null, $force_save = false) {
public function save(FormInterface $form = null, $force_save = false): ProjectCampaignForm
{

if(!$form) $form = $this->getBuilder()->getForm();
if(!$form->isValid() && !$force_save) throw new FormModelException(Text::get('form-has-errors'));
Expand All @@ -142,7 +148,6 @@ public function save(FormInterface $form = null, $force_save = false) {
throw new FormModelException(Text::get('form-sent-error', implode(', ',$errors)));
}

$data = $form->getData();
$account = $this->getOption('account');
$account->rebuildData(['allowpp' => $data['allowpp']]);

Expand Down
1 change: 1 addition & 0 deletions translations/ca/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,4 @@ project-campaign-activate-impact-calculator: "Al activar la calculadora d'impact
project-campaign-type-label: "Escull tipus de campanya"
project-campaign-type-campaign: "Campanya"
project-campaign-type-permanent: "Permanent"
project-campaign-type-prehelp: "Aquest camp permet escollir el tipus de campanya que es vol fer. Si es vol fer un projecte per rondes s'ha d'escollir `campanya`. Si es vol fer una campanya `permanent`, s'ha d'escollir permanent."
1 change: 1 addition & 0 deletions translations/en/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ project-campaign-activate-impact-calculator: "By activating the impact calculato
project-campaign-type-label: "Choose type of Campaign"
project-campaign-type-campaign: "Campaign"
project-campaign-type-permanent: "Permanent"
project-campaign-type-prehelp: "This field allows you to choose the type of campaign you want to do. If you want to make a project for rounds you have to choose `campaign`. If you want to make a `permanent` campaign, you have to choose permanent."
1 change: 1 addition & 0 deletions translations/es/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,4 @@ project-campaign-activate-impact-calculator: "Al activar la calculadora de impac
project-campaign-type-label: "Escoge tipo de campaña"
project-campaign-type-campaign: "Campaña"
project-campaign-type-permanent: "Permanente"
project-campaign-type-prehelp: "Este campo permite escoger el tipo de campaña que se quiere hacer. Si se quiere hacer un proyecto por rondas se tiene que escoger `campaña`, si se quiere hacer una campaña permanente se debe escoger `permanente`."