Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted November 8, 20168 yr 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.
November 8, 20168 yr Author 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.
Archived
This topic is now archived and is closed to further replies.