Skip to content

Commit

Permalink
Merge pull request #18 from BFoucher/feature/custom-submit-button
Browse files Browse the repository at this point in the history
choice for submit button color
  • Loading branch information
Charlie-Lucas authored Feb 22, 2017
2 parents edf7670 + d1acc6a commit c1060cc
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Entity/WidgetForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ class WidgetForm extends Widget
*/
protected $submitLabel;

/**
* @var string
*
* Nullable for not break with old install but it's required in form and default value is set in template
* @ORM\Column(name="submit_class", type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
protected $submitClass;

/**
* @ORM\OneToMany(targetEntity="Victoire\Widget\FormBundle\Entity\WidgetFormQuestion", mappedBy="form", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"position" = "ASC"})
Expand Down Expand Up @@ -183,6 +192,7 @@ public function __construct()
parent::__construct();
$this->questions = new ArrayCollection();
$this->submitIcon = 'fa-location-arrow';
$this->submitClass = 'primary';
}

/**
Expand Down Expand Up @@ -738,4 +748,20 @@ public function setAdminSubject($adminSubject)
{
$this->adminSubject = $adminSubject;
}

/**
* @return mixed
*/
public function getSubmitClass()
{
return $this->submitClass;
}

/**
* @param mixed $submitClass
*/
public function setSubmitClass($submitClass)
{
$this->submitClass = $submitClass;
}
}
12 changes: 12 additions & 0 deletions Form/WidgetFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'label' => 'widget_form.form.submitIcon.label',
'required' => false,
])
->add('submitClass', ChoiceType::class, [
'label' => 'widget_form.form.submitClass.label',
'choices' => [
'widget_form.form.choice.style.label.default' => 'default',
'widget_form.form.choice.style.label.primary' => 'primary',
'widget_form.form.choice.style.label.success' => 'success',
'widget_form.form.choice.style.label.info' => 'info',
'widget_form.form.choice.style.label.warning' => 'warning',
'widget_form.form.choice.style.label.danger' => 'danger',
],
'choices_as_values' => true,
])
->add('successCallback', ChoiceType::class, [
'label' => 'widget_form.form.successCallback.label',
'required' => true,
Expand Down
28 changes: 28 additions & 0 deletions Resources/translations/victoire.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,34 @@
<source>victoire.widget-form.successCallback.assert.badChoice</source>
<target>Please specify an action from the dropdown menu.</target>
</trans-unit>
<trans-unit id="submitClassLabel" resname="widget_form.form.submitClass.label">
<source>widget_form.form.submitClass.label</source>
<target>Submission button Style:</target>
</trans-unit>
<trans-unit id="submitClassDefaultLabel" resname="widget_form.form.choice.style.label.default">
<source>widget_form.form.choice.style.label.default</source>
<target>Default</target>
</trans-unit>
<trans-unit id="submitClassPrimaryLabel" resname="widget_form.form.choice.style.label.primary">
<source>widget_form.form.choice.style.label.primary</source>
<target>Principal</target>
</trans-unit>
<trans-unit id="submitClassSuccessLabel" resname="widget_form.form.choice.style.label.success">
<source>widget_form.form.choice.style.label.success</source>
<target>Succès</target>
</trans-unit>
<trans-unit id="submitClassInfoLabel" resname="widget_form.form.choice.style.label.info">
<source>widget_form.form.choice.style.label.info</source>
<target>Informatif</target>
</trans-unit>
<trans-unit id="submitClassWarningLabel" resname="widget_form.form.choice.style.label.warning">
<source>widget_form.form.choice.style.label.warning</source>
<target>Avertissement</target>
</trans-unit>
<trans-unit id="submitClassDangerLabel" resname="widget_form.form.choice.style.label.danger">
<source>widget_form.form.choice.style.label.danger</source>
<target>Danger</target>
</trans-unit>
</body>
</file>
</xliff>
28 changes: 28 additions & 0 deletions Resources/translations/victoire.es.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,34 @@
<source>victoire.widget-form.successCallback.assert.badChoice</source>
<target>Por favor especificar una acción en el menú desplegable.</target>
</trans-unit>
<trans-unit id="submitClassLabel" resname="widget_form.form.submitClass.label">
<source>widget_form.form.submitClass.label</source>
<target>Botón estilo :</target>
</trans-unit>
<trans-unit id="submitClassDefaultLabel" resname="widget_form.form.choice.style.label.default">
<source>widget_form.form.choice.style.label.default</source>
<target>Defecto</target>
</trans-unit>
<trans-unit id="submitClassPrimaryLabel" resname="widget_form.form.choice.style.label.primary">
<source>widget_form.form.choice.style.label.primary</source>
<target>Primario</target>
</trans-unit>
<trans-unit id="submitClassSuccessLabel" resname="widget_form.form.choice.style.label.success">
<source>widget_form.form.choice.style.label.success</source>
<target>éxito</target>
</trans-unit>
<trans-unit id="submitClassInfoLabel" resname="widget_form.form.choice.style.label.info">
<source>widget_form.form.choice.style.label.info</source>
<target>Informativo</target>
</trans-unit>
<trans-unit id="submitClassWarningLabel" resname="widget_form.form.choice.style.label.warning">
<source>widget_form.form.choice.style.label.warning</source>
<target>Advertencia</target>
</trans-unit>
<trans-unit id="submitClassDangerLabel" resname="widget_form.form.choice.style.label.danger">
<source>widget_form.form.choice.style.label.danger</source>
<target>Peligro</target>
</trans-unit>
</body>
</file>
</xliff>
28 changes: 28 additions & 0 deletions Resources/translations/victoire.fr.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,34 @@
<source>widget_form.form.adminSubject.help_block</source>
<target>Indiquez le sujet du message que le destinataire verra.</target>
</trans-unit>
<trans-unit id="submitClassLabel" resname="widget_form.form.submitClass.label">
<source>widget_form.form.submitClass.label</source>
<target>Style du bouton de soumission:</target>
</trans-unit>
<trans-unit id="submitClassDefaultLabel" resname="widget_form.form.choice.style.label.default">
<source>widget_form.form.choice.style.label.default</source>
<target>Par défaut</target>
</trans-unit>
<trans-unit id="submitClassPrimaryLabel" resname="widget_form.form.choice.style.label.primary">
<source>widget_form.form.choice.style.label.primary</source>
<target>Primary</target>
</trans-unit>
<trans-unit id="submitClassSuccessLabel" resname="widget_form.form.choice.style.label.success">
<source>widget_form.form.choice.style.label.success</source>
<target>Succes</target>
</trans-unit>
<trans-unit id="submitClassInfoLabel" resname="widget_form.form.choice.style.label.info">
<source>widget_form.form.choice.style.label.info</source>
<target>Informative</target>
</trans-unit>
<trans-unit id="submitClassWarningLabel" resname="widget_form.form.choice.style.label.warning">
<source>widget_form.form.choice.style.label.warning</source>
<target>Warning</target>
</trans-unit>
<trans-unit id="submitClassDangerLabel" resname="widget_form.form.choice.style.label.danger">
<source>widget_form.form.choice.style.label.danger</source>
<target>Danger</target>
</trans-unit>
</body>
</file>
</xliff>
1 change: 1 addition & 0 deletions Resources/views/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</div>
<div class="vic-col-md-6">
{{ form_row(form.submitIcon) }}
{{ form_row(form.submitClass) }}
</div>
</div>
<div class="vic-form-group vic-well">
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
{% endfor %}
</div>

<button type="submit" class="btn btn-primary pull-right">
<button type="submit" class="btn btn-{{ submitClass|default('primary') }} pull-right">
{% if submitIcon %}
<span class="fa {{ submitIcon }}"></span>&nbsp;
{% endif %}
Expand Down

0 comments on commit c1060cc

Please sign in to comment.