Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Adriano Faria Posted November 8, 2016 Posted November 8, 2016 Can you please add a minItems to the Stack field? class _Stack extends FormAbstract { /** * @brief Default Options */ protected $defaultOptions = array( 'stackFieldType' => 'Text', 'removeEmptyValues' => TRUE, 'maxItems' => NULL ); Sometimes we need to limit by a min entries too, not only max. Thank you.
Adriano Faria Posted November 8, 2016 Author Posted November 8, 2016 I'm able to make a validation: $form->add( new \IPS\Helpers\Form\Stack( 'question_wrong', isset( $question['question_wrong']) ? json_decode( $question['question_wrong'], TRUE ) : array(), TRUE, array( 'maxItems' => $container->max_answers-1 ), function( $val ) use( $container ) { if( $val and is_array( $val ) AND count( $val ) < $container->min_answers-1 ) { throw new \InvalidArgumentException( 'quizz_min_number_questions_required' ); } }, NULL, NULL, 'question_wrong' ) ); But I'm also able to make it for max items, so for consistency sake, minItems would save us time.
bfarber Posted November 8, 2016 Posted November 8, 2016 Good suggestion, I've raised it internally for further consideration
Recommended Posts
Archived
This topic is now archived and is closed to further replies.