August 17, 2016 in Developer Connection
Can you please change the method \IPS\Content\Controller::edit() to allow the use of custom templates to display the edit form? Right now the code is this:
/* Build the form */
$form = $item->buildEditForm();
if ( $values = $form->values() )
/* [...] */
$this->_setBreadcrumbAndTitle( $item );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'edit_title', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $item::$title ) ) ) ), $form );
You allow us to add/change fields in the buildEditForm() method but we still can't choose a custom template. I had to copy/paste the whole function just to be able to use this line:
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'MODULE', 'APP' ) ), 'TEMPLATE' ), $arguments );
You can also do a theme hook on editContentForm and overload the function itself (in PHP mode). You could check the current app and controller and just return different output if it meets your criteria.
It's helpful that the form is passed in as an object instead of being converted to a string.
Indeed, but I don't want to make an hook each time I want to add a specific template for an edit form. If they let us somehow specify the template in the $form class itself and it gets used when the __toString function in the class is called it would be much more convenient. Not to mention this would "fix" all the other forms too making it available globally and easily
I have raised the suggestion internally for further review and discussion, thanks!
This topic is now archived and is closed to further replies.
Started November 29
Started 1 hour ago
Started Wednesday at 04:53 AM