Jump to content

Problem with form stack custom field type


DawPi

Recommended Posts

Hello,

it's pretty simple to reproduce. The stack part:

$form->add( new \IPS\Helpers\Form\Stack( 'myapp_authors', ! empty( $authors ) ? $authors : array(), TRUE, array( 'stackFieldType' => '\IPS\myapp\Form\File', 'maxItems' => 5, 'key' => array( 'placeholder' => \IPS\Member::loggedIn()->language()->addToStack( 'myapp_enter_name_placeholder' ), 'size' => 20 ), 'value' => array( 'min' => 0, 'max' => 100 ) ), NULL, NULL, NULL, 'myapp_authors' ) );

And custom form field type constructor from myapp\(sources)Form\File:

	/**
	 * Constructor
	 * Creates the two date objects
	 *
	 * @param	string		$name			Form helper name
	 * @param	mixed		$defaultValue	Default value for the helper
	 * @param	bool		$required		Helper is required (TRUE) or not (FALSE)
	 * @param	array		$options		Options for the helper instance
	 * @see		\IPS\Helpers\Form\Abstract::__construct
	 * @return	void
	 */
	public function __construct( $name, $defaultValue=NULL, $required=FALSE, $options=array() )
	{
		$options = array_merge( $this->defaultOptions, $options );

		parent::__construct( $name, $defaultValue, $required, $options );

        $this->keyField = new \IPS\Helpers\Form\Member( "{$name}[key]", isset( $defaultValue['key'] ) ? \IPS\Member::load( $defaultValue['key'] ) : NULL, TRUE, array(), NULL, NULL, NULL, "{$name}[key]" );
        
		$this->valueField = new \IPS\Helpers\Form\Number( "{$name}[value]", isset( $defaultValue['value'] ) ? $defaultValue['value'] : NULL, FALSE, isset( $options['value'] ) ? $options['value'] : array() );
	}

 

And this is how it works and looks like:

 

Is this a known issue or someone know how to fix it? 🤔

Thanks in advance!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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