0

I'm trying to add button input to the form element. I'd like the rendered code to be <input type="button" ..."> I tried setting attribs field like so:

$this->addElement('submit', 'cancel', array(
                'ignore' => true,
                'label' => 'Anuluj',
                'attribs'=>array('class' => 'class_name', 'type' => 'button')  )
        );

but i still got <input type="submit" ..."> instead <input type="button" ...">

Setting class attribute works, but setting the type doesn't. Any Idea to get type="button"?

2 Answers 2

2

Use button as the first parameter instead, which will give you a <button> HTML element instead (functionally the same as <input type="button" ..>).

Sign up to request clarification or add additional context in comments.

Comments

0

Please use the below code for button

    $this->addElement('button', 'submitted');
    $submitElement = $this->getElement('submitted');
    $submitElement->setAttrib('class',"btn-primary btn");
    $submitElement->setAttrib('value', 'submitted');
    $submitElement->setLabel('SUBMIT');

The Html code is,

<button name="submitted" id="submitted" type="button" class="btn-primary btn">SUBMIT</button>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.