In this case if I have to move the Form->create() out of this view I'll be
doing code duplication in every form.
The solution I found was create a method "setContext($context)" in a
inherited Form helper to initialize before the Form->input() in the view
block.
Is there any chance this become functional this way in the future?
Em quinta-feira, 31 de julho de 2014 08h58min56s UTC-3, Tiago Barrionuevo
escreveu:
>
> Yes, it returns an entity. I can simplify a little more:
>
> <div>
> <h2><?php echo 'Test Cases - VIEW BLOCK'; ?></h2>
> <div class="container">
> <?php
> echo $this->Form->create($test);
> echo $this->fetch('cadastro_data');
> echo $this->Form->end();
> ?>
> </div>
> </div>
>
> After some debugging I guess I found the problem!
> Cause "$this->Form->create($test)" is in other view that the "
> $this->Form->input(...);", the Form->inputs are processed before the
> Form->Create and it has no entity yet!
>
>
> Em quinta-feira, 31 de julho de 2014 08h28min13s UTC-3, José Lorenzo
> escreveu:
>>
>> What does $this->get('test') return? Is it an entity?
>>
>> On Thursday, July 31, 2014 3:47:47 AM UTC+2, Tiago Barrionuevo wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to build a form, with a CakePHP 3 application, using view
>>> blocks but I can't get it to work. It seens that the Form->create() doesn't
>>> find the model.
>>> I build a simple form to test it (controller Tests):
>>>
>>>
>>> src/Template/Tests/view_block.ctp
>>>
>>> <?php
>>> $this->set('cadastro_title', $this->get('search_modulename') . ' -
>>> VIEW_BLOCK');
>>> $this->set('cadastro_entity', $this->get('test'));
>>>
>>> $this->extend('/Common/cadastro_editor');
>>>
>>> $this->start('cadastro_data');
>>> ?>
>>>
>>> <fieldset>
>>> <div class="row">
>>> <?= $this->Form->input('id', array('label' => 'Id:' ));?>
>>> </div>
>>>
>>> <div class="row">
>>> <?= $this->Form->input('name', array('label' => 'Name:' ));?>
>>> </div>
>>>
>>> <div class="row">
>>> <?= $this->Form->input('result', array('label' => 'Result:' ));?>
>>> </div>
>>> </fieldset>
>>>
>>> <?php $this->end(); ?>
>>>
>>>
>>> ---------------------------------------------------------------------------
>>> src/Template/Common/cadastro_editor.ctp
>>>
>>> <div>
>>> <h2><?php echo $this->get('cadastro_title'); ?></h2>
>>>
>>> <div class="container">
>>> <?php
>>> echo $this->Form->create($this->get('test') );
>>> //echo $this->Form->create($this->get('cadastro_entity') );
>>>
>>> echo $this->fetch('cadastro_data');
>>>
>>> echo $this->Form->end();
>>> ?>
>>> </div>
>>> </div>
>>>
>>> ======================================
>>> The same form without view block works ok:
>>>
>>> <?php
>>> $this->set('cadastro_title', $this->get('search_modulename') . ' -
>>> VIEW');
>>> ?>
>>> <div>
>>> <h2><?php echo $this->get('cadastro_title'); ?></h2>
>>>
>>> <div class="container">
>>> <?php
>>> echo $this->Form->create($this->get('test') );
>>> ?>
>>>
>>> <fieldset>
>>> <div class="row">
>>> <?= $this->Form->input('id', array('type'=>'text', 'label' =>
>>> 'Id:' ));?>
>>> </div>
>>>
>>> <div class="row">
>>> <?= $this->Form->input('name', array('label' => 'Name:' ));?>
>>> </div>
>>>
>>> <div class="row">
>>> <?= $this->Form->input('result', array('label' => 'Result:' ));
>>> ?>
>>> </div>
>>> </fieldset>
>>> </div>
>>> </div>
>>>
>>>
>>> Maybe I'm doing something wrong!
>>>
>>> Thanks in advance
>>>
>>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.