Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

New Form Element don't bind loaded data from model

Hi,

I've created a new form element 'url' for the html-element <input type="url" ...>.

class Url extends Element
{
    public function __construct($name, $attributes=null)
    {
        parent::__construct($name, $attributes);
    }

    public function render($attributes = null) 
    {   
        if ($attributes != null && is_array($attributes))
        {
            foreach ($attributes as $new_attr => $value)
            {
                $this->_attributes[$new_attr] = $value;
            }
        }

        $html =  '<input type="url" ';
        foreach ($this->_attributes as $attr => $value)
        {
            $html .= $attr.'="'.$value.'" ';
        }
        $html .= ' />';
        return $html;
    }
}

Creating and updating works fine, but it does not show (or bind) the data to the edit-form from the loaded entity.

$note = EntitiesNotes::findFirstById($id);
$form = new NoteForm($note);

All standard elements that come with phalcon shows the stored data, but the url-field is empty. Rendered HTML-Code shows that the input has no value="" attribute.

Do I have to override another function of the Form\Element?

Thanks alot!

Thanks a lot! :)