record in Create Record is null
According to the docs, this should output the record before it gets created, however it shows up null.
Any idea why?
6 Replies
Is this a mistake? How can you have a record before you create?
anyone?
Looks to me like a copy error in the documentation. In the
EditRecord
class, the getRecord()
method should, as documented, return the corresponding model. However, in the CreateRecord
class, the getRecord()
method will only return the model in the last lifecycle hook afterCreate()
. Before that, you will receive null
. To access the data before that, you will need to use $this->form->getState()
. Do you have an example case in which the $this->halt()
method can be correctly explained?Yes I do!
think about it. how can
$this->getRecord()
be not null if record isn't created yet? can you post the link to docsThis is more for validation purposes. The
$this->halt()
method should already be demonstrated with an example that cannot be easily resolved through validation alone.For validation purpose? That's what validation is for