-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Required fields #104
Comments
We've already integrated jQuery Validation and you can see the general description of how it works in the comments here: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/master/php/class-fieldmanager-field.php#L131-L153 |
I think a working example in the |
I think ultimately we should be able to PHP-require some fields and allow custom validation callbacks. |
I'd also appreciate a working example of this. |
I'd appreciate a working example of this also. The documentation here isn't very helpful: http://api.fieldmanager.org/class-Fieldmanager_Field.html#$validation_rules I assumed I'd be able to do something similar and the jquery validation would handle the rest
This doesn't seem to work and there's not really much documentation as to the format / how this should work. |
Came looking for an example but then found in the Fieldmanager_Field class that you want to pass it in as an attribute, which will add the HTML5 required attribute to the field. If it helps, there's an example at http://api.fieldmanager.org/class-Fieldmanager_Field.html#$attributes |
I tried the same approach and it ended up working out: 'url' => new \Fieldmanager_Link( 'Destination URL', [
'description' => 'All messages are linked to a destination page',
'validation_rules' => [
'required' => true,
'url' => true,
],
'validation_messages' => [
'required' => 'Required',
'url' => 'This is not a URL!',
],
'attributes' => [
'placeholder' => 'https://',
],
] ), |
How do you feel about adding the ability to mark certain fields as "required" (however you might define that)?
The text was updated successfully, but these errors were encountered: