addElement('hidden', 'id'); $this->addRowNumber(); $index = $this->getName(); $this->addElement( 'radio', 'correct', [ 'label' => 'Correct', 'required' => Qs_Request::isGet() || Qs_Request::getPostValue('formPartAction') == 'new', 'multiOptions' => [$this->getName() => ''], 'beforeHelper' => function ($options) use ($index) { $options['name'] = preg_replace('/\[answers\]\[[\d]+\]\[correct\]/', '[correctAnswerIndex]', $options['name']); if (Qs_Request::isPost()) { $options['value'] = Qs_Request::getPostValue($options['name']); } }, ] ); $this->addElement('text', 'text', ['label' => 'Answer', 'required' => true]); $this->addOptionsColumn(); return parent::_initElements(); } }