Set a option in form and entities when we edit it

Hello all

//PostForms.php
$price = new Text(
    'price',
    ['
        class' => 'form-control',
        'value' => 12
    ]
);

//PostsController
public function editAction($id)
{
$id = (int) $id;
if (!$object = Posts::findFirstById($id)) {
    $this->flashSession->error(t('Posts doesn\'t exist.'));

    return $this->currentRedirect();
}
$form   = new PostsForm($object);
$this->view->setVars([
    'form' =>  $form,
    'object' => $object
]);

$this->assets
    ->addJs('backend/js/plugins/staps/jquery.steps.min.js')
    ->addJs('backend/js/plugins/validate/jquery.validate.min.js')
    ->addJs('backend/js/plugins/iCheck/icheck.min.js')
;
$this->assets
    ->addCss('backend/css/plugins/steps/jquery.steps.css')
    ->addCss('backend/css/plugins/iCheck/custom.css')
;
return $this->view->pick($this->router->getControllerName() . '/new');
}

/new.volt

{{ form.render('price')}} //<input type="text" class="form-control" value="0.00" name="price" id="price">

{{ form.render('price', ['value' : 12])}} //same result like above

So I want to overwrite it like

<input type="text" class="form-control" value="12" name="price" id="price">

How to do that?



6.6k

in PostsConyroller:


$this->tag->setDefault('price', 12);


37.8k

Hello

It not working :)