I'm migrating my application to 4.0.5 and I can't use Form\Element.
Fatal error: Uncaught Error: Class 'Phalcon\Forms\Element' not found
Is it a bug or is there another way?
Here is an example:
In Form
$this->add(
new CustomElement('submit', [
'type' => 'buttom',
'name' => $t->_('Entrar'),
'text'=> $t->_('Entrar'),
'value' => $t->_('Entrar'),
'id' => 'kt_login_signin_submit',
'class' => 'btn btn-brand btn-pill btn-elevate'
])
);
My Customer Element
use Phalcon\Forms\Element;
class CustomElement extends Element
{
public function render($attributes = null)
{
$html = null;
if(!$attributes) :
$attributes['type'] = null;
$attributes['id'] = null;
$attributes['name'] = null;
$attributes['class'] = null;
$attributes['text'] = null;
$attributes['value'] = null;
$attributes = $this->getAttributes();
endif;
if(isset($attributes['type']) and !empty($attributes['type'])):
/**
* BUTTOM
*/
if($attributes['type'] == 'buttom'):
$html = '<button id="'.$attributes['id'].'" name="'.$attributes['name'].'" class="'.$attributes['class'].'">'.$attributes['text'].'</button>';
endif;
endif;
return $html;
}
}
Documentation: https://docs.phalcon.io/4.0/en/forms#elements
Please try 'Phalcon\Forms\Element\AbstractElement'
Phalcon\Forms\Element is not exist in the 4.x
Please try 'Phalcon\Forms\Element\AbstractElement'
Phalcon\Forms\Element is not exist in the 4.x
Hi @TimurFlush ,
Thank you!
See the changes below to update the Phalcon 4 documentation:
<?php
use Phalcon\Forms\Element\AbstractElement;
class MyElement extends AbstractElement
{
public function render(array $attributes = null): string
{
$html = '';// HTML
return $html;
}
}
Please, close the issue.
Thank you
Most helpful comment
Hi @TimurFlush ,
Thank you!
See the changes below to update the Phalcon 4 documentation:
Please, close the issue.
Thank you