|
|
@@ -327,9 +327,9 @@ class FormHelper extends Helper
|
|
|
* - `valueSources` The sources that values should be read from. See FormHelper::setValueSources()
|
|
|
* - `templateVars` Provide template variables for the formStart template.
|
|
|
*
|
|
|
- * @param mixed $context The context for which the form is being defined. Can
|
|
|
- * be an ORM entity, ORM resultset, or an array of meta data. You can use false or null
|
|
|
- * to make a context-less form.
|
|
|
+ * @param mixed $context The context for which the form is being defined.
|
|
|
+ * Can be a ContextInterface instance, ORM entity, ORM resultset, or an
|
|
|
+ * array of meta data. You can use false or null to make a context-less form.
|
|
|
* @param array $options An array of html attributes and options.
|
|
|
* @return string An formatted opening FORM tag.
|
|
|
* @link https://book.cakephp.org/3.0/en/views/helpers/form.html#Cake\View\Helper\FormHelper::create
|
|
|
@@ -338,12 +338,16 @@ class FormHelper extends Helper
|
|
|
{
|
|
|
$append = '';
|
|
|
|
|
|
- if (empty($options['context'])) {
|
|
|
- $options['context'] = [];
|
|
|
+ if ($context instanceof ContextInterface) {
|
|
|
+ $this->context($context);
|
|
|
+ } else {
|
|
|
+ if (empty($options['context'])) {
|
|
|
+ $options['context'] = [];
|
|
|
+ }
|
|
|
+ $options['context']['entity'] = $context;
|
|
|
+ $context = $this->_getContext($options['context']);
|
|
|
+ unset($options['context']);
|
|
|
}
|
|
|
- $options['context']['entity'] = $context;
|
|
|
- $context = $this->_getContext($options['context']);
|
|
|
- unset($options['context']);
|
|
|
|
|
|
$isCreate = $context->isCreate();
|
|
|
|