Skip to content

Commit

Permalink
following master
Browse files Browse the repository at this point in the history
  • Loading branch information
phiamo committed Oct 24, 2013
1 parent c755c2d commit 6488ed2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 45 deletions.
13 changes: 2 additions & 11 deletions Controller/ExamplesController.php
Expand Up @@ -97,22 +97,13 @@ public function errorsAction(Request $request)
$form->submit(array(
'textfield1' => 'nix',
'textfield2' => "nothing",
'textfield3' => "nothing"
'textfield3' => "nothing",
"textarea" => "nothing",
));
$form->isValid();
$form2 = $this->createForm($formType2 = new ExampleErrorsFormType(true));
$form2->submit(array(
'textfield1' => 'nix',
'textfield2' => "nothing",
'textfield3' => "nothing"
));
$form2->isValid();

return array(
'form'=>$form->createView(),
'formType' => $formType,
'form2'=>$form2->createView(),
'formType2' => $formType2
);
}
/**
Expand Down
18 changes: 8 additions & 10 deletions Form/Type/ExampleErrorsFormType.php
Expand Up @@ -7,16 +7,18 @@
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class ExampleErrorsFormType extends AbstractType
{
private $formErrors;

public function __construct($formErrors = false) {
$this->formErrors = $formErrors;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder

->add('textfield1', 'text', array(
'label' => 'Form sizes',
'constraints' => new Length(array('min' => 5)),
Expand All @@ -25,15 +27,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'placeholder' => 'input-mini',
)
))
->add('textfield2', 'text', array(
'label_render' => false,
'constraints' => new Email(array('message' => 'Invalid email address')),
'attr' => array(
'class' => 'input-medium',
'placeholder' => 'input-medium',
)
))
->add('textfield3', 'text', array(
->add('textarea', 'textarea', array(
'label_render' => false,
'error_type' => "block",
'constraints' => new Email(array('message' => 'Annother Invalid email address')),
Expand All @@ -42,6 +36,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'placeholder' => 'input-large',
)
))
->add("subform", new ExampleExtendedFormType(), array(
"label_render" => false,
"widget_form_group" => false,
))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
Expand Down
57 changes: 41 additions & 16 deletions Form/Type/ExampleExtendedFormType.php
Expand Up @@ -4,6 +4,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints\NotBlank;

class ExampleExtendedFormType extends AbstractType
{
Expand All @@ -15,41 +16,47 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'horizontal_input_wrapper_class' => 'col-lg-4',
'attr' => array(
'placeholder' => 'col-lg-4',
)
),
'constraints' => new NotBlank(),
))
->add('textfield2', 'text', array(
'label_render' => false,
'horizontal_label_class' => 'col-lg-offset-3',
'horizontal_input_wrapper_class' => 'col-lg-6',
'attr' => array(
'placeholder' => 'col-lg-6',
)
),
'constraints' => new NotBlank(),
))
->add('textfield3', 'text', array(
'label_render' => false,
'horizontal_label_class' => 'col-lg-offset-3',
'horizontal_input_wrapper_class' => 'col-lg-9',
'attr' => array(
'placeholder' => 'col-lg-9',
)
),
'constraints' => new NotBlank(),
))
->add('select1', 'choice', array(
'label_render' => false,
'choices' => array('1' => 'one', '2' => 'two'),
'horizontal_label_class' => 'col-lg-offset-3',
'horizontal_input_wrapper_class' => 'col-lg-4',
'constraints' => new NotBlank(),
))
->add('select2', 'choice', array(
'label_render' => false,
'choices' => array('1' => 'one', '2' => 'two'),
'horizontal_label_class' => 'col-lg-offset-3',
'horizontal_input_wrapper_class' => 'col-lg-6',
'constraints' => new NotBlank(),
))
->add('select3', 'choice', array(
'label_render' => false,
'choices' => array('1' => 'one', '2' => 'two'),
'horizontal_label_class' => 'col-lg-offset-3',
'horizontal_input_wrapper_class' => 'col-lg-9',
'constraints' => new NotBlank(),
))
->add('Prepended_Text', 'text', array(
'widget_addon_prepend' => array(
Expand All @@ -58,7 +65,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'horizontal_input_wrapper_class' => 'col-lg-4',
'attr' => array(
'placeholder' => 'col-lg-4',
)
),
'constraints' => new NotBlank(),
))
->add('Prepended_Icon', 'text', array(
'widget_addon_prepend' => array(
Expand All @@ -67,7 +75,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'horizontal_input_wrapper_class' => 'col-lg-9',
'attr' => array(
'placeholder' => 'Which kind of music?',
)
),
'constraints' => new NotBlank(),
))
->add('Appended_Text', 'text', array(
'widget_addon_append' => array(
Expand All @@ -76,7 +85,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'horizontal_input_wrapper_class' => 'col-lg-4',
'attr' => array(
'placeholder' => 'col-lg-4',
)
),
'constraints' => new NotBlank(),
))
->add('Appended_Icon', 'text', array(
'widget_addon_append' => array(
Expand All @@ -86,14 +96,16 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'horizontal_input_wrapper_class' => 'col-lg-9',
'attr' => array(
'placeholder' => 'Which kind of books?',
)
),
'constraints' => new NotBlank(),
))
->add('Checkboxes_Inline', 'choice', array(
'label' => 'Inline checkboxes',
'multiple' => true,
'expanded' => true,
'choices' => array('1' => 'one', '2' => 'two', '3'=>'three'),
'widget_type' => 'inline'
'widget_type' => 'inline',
'constraints' => new NotBlank(),
))
->add('Checkboxes', 'choice', array(
'label' => 'Checkboxes',
Expand All @@ -105,12 +117,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'2' => 'Option two can also be checked and included in form results',
'3' => 'Option three can—yes, you guessed it—also be checked and included in form results'
),
'constraints' => new NotBlank(),
))
->add('Radio_Buttons_Inline', 'choice', array(
'label' => 'Inline Radio buttons',
'expanded' => true,
'choices' => array('1' => 'one', '2' => 'two', '3'=>'three'),
'widget_type' => 'inline'
'widget_type' => 'inline',
'constraints' => new NotBlank(),
))
->add('Radio_Buttons', 'choice', array(
'label' => 'Radio buttons',
Expand All @@ -120,55 +134,66 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'2' => 'Option two can also be checked and included in form results',
'3' => 'Option three can—yes, you guessed it—also be checked and included in form results'
),
'constraints' => new NotBlank(),
))
->add('publicVisible', 'checkbox', array(
'required' => false,
'constraints' => new NotBlank(),
))
->add('time1', 'time', array(
'widget' => 'choice',
'horizontal_input_wrapper_class' => 'col-lg-2'
'horizontal_input_wrapper_class' => 'col-lg-2',
'constraints' => new NotBlank(),
))
->add('date1', 'date', array(
'horizontal_input_wrapper_class' => 'col-lg-2',
'widget' => 'choice',
'constraints' => new NotBlank(),
))
->add('date_time1', 'datetime', array(
'widget' => 'choice',
'horizontal_input_wrapper_class' => 'col-lg-2'
'horizontal_input_wrapper_class' => 'col-lg-2',
'constraints' => new NotBlank(),
))
->add('Prefix_Text', 'text', array(
'widget_prefix' => "Prefix Text",
'horizontal_input_wrapper_class' => 'col-lg-4',
'attr' => array(
'placeholder' => 'col-lg-4',
)
),
'constraints' => new NotBlank(),
))
->add('Suffix_Text', 'text', array(
'horizontal_input_wrapper_class' => 'col-lg-4',
'widget_suffix' => "Suffix Text",
'attr' => array(
'class' => 'col-lg-4',
'placeholder' => 'col-lg-4',
)
),
'constraints' => new NotBlank(),
))
->add('Money_default', 'money', array(
'horizontal_input_wrapper_class' => 'col-lg-4',
'attr' => array(
'placeholder' => 'col-lg-4',
)
),
'constraints' => new NotBlank(),
))
->add('Percent_default', 'percent', array(
'horizontal_input_wrapper_class' => 'col-lg-4',
'attr' => array(
'placeholder' => 'col-lg-4',
)
),
'constraints' => new NotBlank(),
))
->add('Required_false', 'text', array(
'required' => false,
'constraints' => new NotBlank(),
))
->add('Required_asterisk_false', 'text', array(
'required' => true,
'render_required_asterisk' => false
'render_required_asterisk' => false,
'constraints' => new NotBlank(),
))
;
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Examples/components.html.twig
Expand Up @@ -16,7 +16,7 @@
{% block subnavbar %}
{% embed '@MopaBootstrap/Navbar/subnavbar.html.twig' %}
{% block menu %}
{{ mopa_bootstrap_menu('MopaBootstrapSandboxBundle:Builder:createComponentsSubnavMenu') }}
{{ mopa_bootstrap_menu('MopaBootstrapSandboxBundle:Builder:createComponentsSubnavMenu', {'automenu': 'pills'}) }}
{% endblock %}
{% endembed %}
{% endblock subnavbar %}
Expand Down
7 changes: 0 additions & 7 deletions Resources/views/Examples/errors.html.twig
Expand Up @@ -12,13 +12,6 @@
<button type="reset" class="btn">Cancel</button>
</div>
</form>
<form class="form-horizontal" id="your_form_name2" method="POST">
{{ form_widget(form2) }}
<div class="form-actions">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="reset" class="btn">Cancel</button>
</div>
</form>
</div>
<div class="col-lg-6">
<h3>The action to generate this page simulates the state after a form submission</h3>
Expand Down

0 comments on commit 6488ed2

Please sign in to comment.