1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Fix a type issue with FormView juggling

Summary:
When you click the pencil icon in the Maniphest task list, we currently fatal:

  Argument 1 passed to PhabricatorCustomFieldList::appendFieldsToForm() must be an instance of AphrontFormView, instance of PHUIFormLayoutView given, called in /core/lib/phabricator/src/applications/maniphest/controller/ManiphestTaskEditController.php on line 576 and defined

This is because we build an `AphrontFormView` noramlly, but a `PHUIFormLayoutView` for dialogs, since they don't take a full form (they render their own form tag).

Instead, always build an `AphrontFormView` and just pull the `PHUIFormLayoutView` out of it when we're ready to put it in a dialog. This means `$form` is always the same type of object, and is generally better and makes more sense.

Test Plan: Clicked pencil edit icon in Maniphest task list.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran, carl

Differential Revision: https://secure.phabricator.com/D8324
This commit is contained in:
epriestley 2014-02-24 12:20:49 -08:00
parent 5f95f2b6d5
commit a31a7809b0
2 changed files with 13 additions and 13 deletions

View file

@ -460,14 +460,10 @@ final class ManiphestTaskEditController extends ManiphestController {
$project_tokenizer_id = celerity_generate_unique_node_id();
if ($request->isAjax()) {
$form = new PHUIFormLayoutView();
} else {
$form = new AphrontFormView();
$form
->setUser($user)
->addHiddenInput('template', $template_id);
}
$form = new AphrontFormView();
$form
->setUser($user)
->addHiddenInput('template', $template_id);
if ($parent_task) {
$form
@ -627,7 +623,7 @@ final class ManiphestTaskEditController extends ManiphestController {
->appendChild(
array(
$error_view,
$form,
$form->buildLayoutView(),
))
->addCancelButton($cancel_uri)
->addSubmitButton($button_name);

View file

@ -81,12 +81,16 @@ final class AphrontFormView extends AphrontView {
$this->getUser()));
}
public function render() {
require_celerity_resource('phui-form-view-css');
$layout = id (new PHUIFormLayoutView())
public function buildLayoutView() {
return id(new PHUIFormLayoutView())
->appendChild($this->renderDataInputs())
->appendChild($this->renderChildren());
}
public function render() {
require_celerity_resource('phui-form-view-css');
$layout = $this->buildLayoutView();
if (!$this->user) {
throw new Exception(pht('You must pass the user to AphrontFormView.'));