Tagged: conditions, Required, validation
- This topic has 7 replies, 5 voices, and was last updated 4 years, 5 months ago by
vayu.
-
AuthorPosts
-
-
November 22, 2015 at 8:21 pm #5057
tatamataMemberHello,
I want to show required field only if condition is met. But even if condition is not met required field is still passed for validation. Any advice on how to work around this?
piklist('field', array( 'type' => 'checkbox', 'field' => 'alone', 'label' => 'Alone?', 'choices' => array( 'yes' => 'Yes' ) )); piklist('field', array( 'type' => 'text', 'field' => 'another_one', 'required' => true, 'conditions' => array( array( 'field' => 'alone', 'value' => 'yes' ) ) )); -
November 23, 2015 at 12:05 pm #5070
-
December 10, 2015 at 7:09 am #5290
fritsgarrerMemberIsn’t it possible to add a ‘required’ subparameter to the ‘conditions’ parameter? And if used it overides the ‘required’ parameter in the field declaration.
piklist('field', array( 'type' => 'text' ,'scope' => 'post_meta' ,'field' => 'name' ,'label' => __('Name') ,'required' => true //void if used within conditions parameter ,'conditions' => array( array( 'field' => 'master-field' ,'value' => 'yes' ,'required' => true ) ) )); -
December 10, 2015 at 3:55 pm #5294
SteveKeymaster@fritsgarrer– Welcome to the Piklist community!
required does not go in the conditions array. This is still an issue. However, a work around might be to put your fields under different tabs in a WorkFlow. You can easily wrap the field in a standard PHP conditional that way.
-
December 15, 2015 at 1:23 pm #5351
fritsgarrerMemberUnfortunately workflows is not a possibility for my use.
Can you tell me why you choose not to put the possibility of “required” into the conditions array? I personally don’t see why it would be a bad thing. But maybe I’m thinking the wrong way for a sollution.
btw what I forgot to say in my last post: Piklist is in my opinion the “one plugin to rule them all”. Where I used to have about 12 plugins I now only use Piklist and Yoast.
-
December 15, 2015 at 5:43 pm #5352
abmcrMemberI also need a required condition into a validation.
May be as future feature in new version
Thank you -
December 16, 2015 at 10:39 am #5356
SteveKeymaster@fritsgarrer– It’s not that we choose not to, it’s just that we haven’t implemented yet. Currently, we are working on getting our unit tests complete and getting Piklist to v1.0. We want to implement this, but it’s a feature request, and we are holding off on feature requests until v1.0.
-
September 6, 2017 at 10:01 am #8380
vayuMemberI miss this feature as well!
-
-
AuthorPosts
- You must be logged in to reply to this topic.