Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Remove validation on field with Fieldset
  • Hi, 

    I want to use Fieldset on my model, it's work. On the field "age", i have set a validation "required" and "numeric". And i have set a default value "20".

    But in a form, i want to hide the field. For this, i use "$form->disable('age');

    But the validation()->run(); say me he has an error on the field "age". How i can disable the field in the validation before use run(); Or put the default value "20" ?
  • $form->field('age')->delete_rule('required');

    in your controller, before you run the validation.
  • Thanks !

    Note: You have the same problem with your example here : http://fuelphp.com/dev-docs/packages/auth/examples/opauth.html#/registration

    With the field "group_id"
  • Don't think group_id is defined as required in the model?
  • Yes, it is : https://github.com/fuel/auth/blob/1.6/master/classes/model/auth/user.php#L49

    And in the doc you say : 
    • Every user is a member of one, and exactly one, group
  • You are absolutely right, I was sleeping. I'll update the docs.

    It needs

        $form->field('group_id')->delete_rule('required')->delete_rule('is_numeric');

    after disabling it.

    You need to do the same in for the provider login form, where you also need to disable the rules for the email field (which is also removed).
  • Ok thanks Harro ;-)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion