Jump to content

Add minItems to Stack field


Adriano Faria

Recommended Posts

Posted

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.

Posted

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...