Editable form

@return Mutable
435191
public function form()
    {
        return $this->scaffoldForm()
                    ->without(['slug'])
                    ->update('parent_id', function (FormElement $element) {
                        $control = new Select('parent_id');
                        $control->setOptions(['' => '--Select--'] + pages()->lists());

                        return $element->setInput($control);
                    });
    }
560919
public function remoteEditForm()
    {
        $url = $this->getRequest()->requestVar('embedurl');
        $form = null;
        $form = Injector::inst()->get(RemoteFileFormFactory::class)
            ->getForm(
                $this->getOwner(),
                'remoteEditForm',
                ['type' => 'edit', 'url' => $url]
            );
        return $form;
    }
1015441
public function createComponentFilter()
	{
		$form = new Form($this, 'filter');

		$form->setMethod(static::$form_method);

		$form->setTranslator($this->getTranslator());

		/**
		 * InlineEdit part
		 */
		$inline_edit_container = $form->addContainer('inline_edit');

		if ($this->inlineEdit instanceof InlineEdit) {
			$inline_edit_container->addSubmit('submit', 'ublaboo_datagrid.save')
				->setValidationScope([$inline_edit_container]);
			$inline_edit_container->addSubmit('cancel', 'ublaboo_datagrid.cancel')
				->setValidationScope(false);

			$this->inlineEdit->onControlAdd($inline_edit_container);
			$this->inlineEdit->onControlAfterAdd($inline_edit_container);
		}

		/**
		 * InlineAdd part
		 */
		$inline_add_container = $form->addContainer('inline_add');

		if ($this->inlineAdd instanceof InlineEdit) {
			$inline_add_container->addSubmit('submit', 'ublaboo_datagrid.save')
				->setValidationScope([$inline_add_container]);
			$inline_add_container->addSubmit('cancel', 'ublaboo_datagrid.cancel')
				->setValidationScope(false)
				->setAttribute('data-datagrid-cancel-inline-add', true);

			$this->inlineAdd->onControlAdd($inline_add_container);
			$this->inlineAdd->onControlAfterAdd($inline_add_container);
		}

		/**
		 * ItemDetail form part
		 */
		$items_detail_form = $this->getItemDetailForm();

		if ($items_detail_form instanceof Nette\Forms\Container) {
			$form['items_detail_form'] = $items_detail_form;
		}

		/**
		 * Filter part
		 */
		$filter_container = $form->addContainer('filter');

		foreach ($this->filters as $filter) {
			$filter->addToFormContainer($filter_container);
		}

		if (!$this->hasAutoSubmit()) {
			$filter_container['submit'] = $this->getFilterSubmitButton();
		}

		/**
		 * Group action part
		 */
		$group_action_container = $form->addContainer('group_action');

		if ($this->hasGroupActions()) {
			$this->getGroupActionCollection()->addToFormContainer($group_action_container);
		}

		if (!$form->isSubmitted()) {
			$this->setFilterContainerDefaults($form['filter'], $this->filter);
		}

		/**
		 * Per page part
		 */
		$form->addSelect('per_page', '', $this->getItemsPerPageList())
			->setTranslator(null);

		if (!$form->isSubmitted()) {
			$form['per_page']->setValue($this->getPerPage());
		}

		$form->addSubmit('per_page_submit', 'ublaboo_datagrid.per_page_submit')
			->setValidationScope([$form['per_page']]);

		$form->onSubmit[] = [$this, 'filterSucceeded'];
	}
578836
public function editAction()
    {
        if(method_exists($this, 'getEditForm'))
        {
            $form = $this->getEditForm();
        }
        else
        {
            $form = $this->getForm();
        }

        $id = $this->getEvent()
                ->getRouteMatch()
                ->getParam('id', 0);

        $form->add([
            'type'       => 'Zend\Form\Element\Hidden',
            'name'       => 'id',
            'attributes' => [
                'id'    => 'id',
                'value' => $id,
            ],
            'filters'    => [
                [
                    'name' => 'Int',
                ],
            ],
            'validators' => [
                [
                    'name' => 'Digits',
                ],
            ],
        ]);

        $em            = $this->getEntityManager();
        $objRepository = $em->getRepository($this->getEntityClass());
        $entity        = $objRepository->find($id);
        $form->bind($entity);

        $redirectUrl = $this->url()->fromRoute($this->getActionRoute(), [], true);
        $prg         = $this->fileprg($form, $redirectUrl, true);

        if($prg instanceof Response)
        {
            return $prg;
        }
        elseif($prg === false)
        {
            $this->getEventManager()->trigger('getForm', $this, [
                'form'        => $form,
                'entityClass' => $this->getEntityClass(),
                'id'          => $id,
                'entity'      => $entity,
            ]);

            return [
                'entityForm' => $form,
                'entity'     => $entity,
            ];
        }

        $this->getEventManager()->trigger('getForm', $this, [
            'form'        => $form,
            'entityClass' => $this->getEntityClass(),
            'id'          => $id,
            'entity'      => $entity,
        ]);

        $savedEntity = $this->getEntityService()->save($form, $entity);

        if(!$savedEntity)
        {
            return [
                'entityForm' => $form,
                'entity'     => $entity,
            ];
        }

        $this->flashMessenger()->addSuccessMessage($this->getServiceLocator()
                        ->get('translator')
                        ->translate($this->successEditMessage));

        return $this->redirect()->toRoute($this->getActionRoute('list'), [], true);
    }
646525
public function edit($id)
    {
        $record = $this->model->findOrFail($id);

        $this->viewData['record'] = $record;

        $this->viewData['formMethod'] = 'PUT';
        $this->viewData['formAction'] = 'user.update';

        return view($this->defaultFormView, $this->viewData);
    }
595682
public function setEditable($editable = true)
    {
        foreach ($this->results as $name) {
            $this->columns->offsetGet($name)->setEditable($editable);
        }

        return $this;
    }
366219
public function editAction()
    {
        $id = $this->params()->fromRoute('id');
        $ids = [];
        if (! empty($id) && ! is_array($id)) {
            $ids = explode(',', $id);
        }
        if (empty($ids)) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('The file ID(s) was not specified.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }

        try {
            $filesList = $this->getFileService()->getFilesList($ids);
        } catch (RuntimeException $e) {
            $this->flashMessenger()->addMessage($e->getMessage());
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }
        if ($filesList->isEmpty()) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('No files, available for editing.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }

        $form = $this->getFileEditForm();
        $form->setAttribute(
            'action',
            $this->url()->fromRoute(
                'sc-admin/file/edit',
                ['id' => $id]
            )
        );
        $form->bind($filesList);
        if ($this->getRequest()->isPost()) {
            $form->setData($this->params()->fromPost());
            if ($form->isValid()) {
                $this->getFileService()->saveFiles($filesList);
            }
        }
        return new ViewModel([
            'form' => $form
        ]);
    }
55105
public function isEditable() {

		$editable = [ IApproval::STATUS_SUBMITTED, IApproval::STATUS_RE_SUBMIT, IApproval::STATUS_UPLIFT_FREEZE, IApproval::STATUS_UPLIFT_BLOCK ];

		return !in_array( $this->status, $editable );
	}
1034726
public function editableFields()
    {
        $ignored = [];
        foreach ($this->groups() as $group) {
            if ($group->getCondition() && $group->getCondition()->fail()) {
                $ignored = array_merge($ignored, $group->fieldNames());
            }
        }

        return $this->fields()->filter(function (Field $field) use ($ignored) {
            return $field->isEditable() && !in_array($field->name(), $ignored);
        });
    }
462044
public function editAction()
    {
        $id = (int) $this->params()->fromRoute('id', null);

        $request = $this->getRequest();
        $service = $this->getService();
        $entity  = $service->getById($id);

        $form     = $this->getEditForm();
        $form->bind($entity);

        if ($request->getQuery()->get('redirect')) {
            $redirect = $request->getQuery()->get('redirect');
        } else {
            $redirect = false;
        }

        $redirectUrl = $this->url()->fromRoute($this->getEditActionRoute(), array('id' => $id)) . ($redirect ? '?redirect=' . $redirect : '');
        $prg = $this->prg($redirectUrl, true);

        if ($prg instanceof Response) {
            return $prg;
        } elseif ($prg === false) {
            return array(
                'options'  => $this->getOptions(),
                'id'       => $id,
                'form'     => $form,
                'redirect' => $redirect,
            );
        }

        $post   = $prg;
        $entity = $service->update($id, $post);

        $redirect = isset($prg['redirect']) ? $prg['redirect'] : null;

        if (!$entity) {
            return array(
                'options'  => $this->getOptions(),
                'id'       => $id,
                'form'     => $form,
                'redirect' => $redirect,
            );
        }

        return $this->redirect()->toUrl($this->url()->fromRoute($this->getRouteIdentifierPrefix()) . ($redirect ? '?redirect='.$redirect : ''));
    }
259434
protected function createComponentEditForm(): Form
	{
		$form = $this->formFactory->create();

		$form->addText('name', 'default.name')
			->setRequired();

		if ($this->editConst) {
			$form->addText('const', 'webManager.web.content.const')
				->setRequired();

			$form->addSelectUntranslated('locale', 'webManager.web.pages.locale')
				->setItems($this->localeService->allowed);
		}

		$form->addText('title', 'webManager.web.content.contentTitle')
			->addRule(Form::MAX_LENGTH, null, 150)
			->setRequired(false);

		$form->addTextArea('keywords', 'webManager.web.content.keywords');

		$form->addImageUpload('image', 'webManager.web.content.photo', 'webManager.web.content.photoDelete')
			->setNamespace('content')
			->setPreview('300x100');

		$form->addColor('background', 'webManager.web.content.background');

		$form->addTextArea('description', 'webManager.web.content.description');

		$form->addTextEditor('content', 'webManager.web.content.content');

		$form->addSubmit('save', 'form.save');

		$form->addLink('back', 'form.back', $this->getBacklink());

		$form->onSuccess[] = [$this, 'editFormSucceeded'];

		return $form;
	}
976272
protected function getSeparatedSelectableInput()
	{
		switch ($this->type)
		{
			case self::TYPE_CHECKBOX:
				$method = 'checkBox';
				break;
			case self::TYPE_RADIO:
				$method = 'radioButton';
				break;
			default:
				throw new CException('This method can be used with only selectable control', E_USER_ERROR);
		}

		$control = $this->form->{$method}($this->model, $this->attribute, $this->htmlOptions);
		$hidden  = '';

		$hasHiddenField = (array_key_exists('uncheckValue', $this->htmlOptions) && $this->htmlOptions['uncheckValue'] === null)
			? false
			: true;

		if ($hasHiddenField && preg_match('/\<input .*?type="hidden".*?\/\>/', $control, $matches))
		{
			$hidden = $matches[0];
			$control = str_replace($hidden, '', $control);
		}

		return array($hidden, $control);
	}
343193
private function getActionFormData()
    {
        $request    = oxNew(Request::class);
        $formData   = $request->getRequestEscapedParameter("editval");
        $formData   = $this->normalizeActionFormData($formData);

        return $formData;
    }
133894
public function performDisabledTransformation()
    {
        $newChildren = new FieldList();
        $clone = clone $this;
        if ($clone->getChildren()) {
            foreach ($clone->getChildren() as $child) {
                        /** @var FormField $child */
                $child = $child->transform(new DisabledTransformation());
                $newChildren->push($child);
            }
        }

        $clone->setChildren($newChildren);
        $clone->setDisabled(true);
        $clone->addExtraClass($this->extraClass());
        $clone->setDescription($this->getDescription());
        foreach ($this->attributes as $k => $v) {
            $clone->setAttribute($k, $v);
        }

        return $clone;
    }
737451
public function editRole()
	{
        $this->defaultData();

		$clazz = $this->getCurrentClass();
		$role = $this->getCurrentInstance();

		$formContainer = new tao_actions_form_Role($clazz, $role);
		$myForm = $formContainer->getForm();
		if($myForm->isSubmited()){
			if($myForm->isValid()){

				$formValues = $myForm->getValues();
				$roleService = tao_models_classes_RoleService::singleton();
				$includedRolesProperty = $this->getProperty(GenerisRdf::PROPERTY_ROLE_INCLUDESROLE);

				// We have to make the difference between the old list
				// of included roles and the new ones.
				$oldIncludedRolesUris = $role->getPropertyValues($includedRolesProperty);
				$newIncludedRolesUris = $formValues[GenerisRdf::PROPERTY_ROLE_INCLUDESROLE];
				$removeIncludedRolesUris = array_diff($oldIncludedRolesUris, $newIncludedRolesUris);
				$addIncludedRolesUris = array_diff($newIncludedRolesUris, $oldIncludedRolesUris);

				// Make the changes according to the detected differences.
				foreach ($removeIncludedRolesUris as $rU){
					$r = $this->getResource($rU);
					$roleService->unincludeRole($role, $r);
				}

				foreach ($addIncludedRolesUris as $aU){
					$r = $this->getResource($aU);
					$roleService->includeRole($role, $r);
				}

				// Let's deal with other properties the usual way.
				unset($formValues[$includedRolesProperty->getUri()]);

				$binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($role);
				$role = $binder->bind($myForm->getValues());

				core_kernel_users_Cache::removeIncludedRoles($role); // flush cache for this role.

				$this->setData('selectNode', tao_helpers_Uri::encode($role->getUri()));
				$this->setData('message', __('Role saved'));
				$this->setData('reload', true);
			}
		}

		$this->setData('uri', tao_helpers_Uri::encode($role->getUri()));
		$this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));
		$this->setData('formTitle', 'Edit Role');
		$this->setData('myForm', $myForm->render());
		$this->setView('roles/form.tpl');
	}
947833
public function isObjEditable()
    {
        $model = ($this->currentObj) ? $this->currentObj : $this->proto();
        $method = [ $model, 'isEditable' ];

        if (is_callable($method)) {
            return call_user_func($method);
        }

        return true;
    }
835605
public function editAction()
    {
        $this->view->disable();
        $id     = $this->request->getPost('hidden_id');    
        $user   = Users::findFirstById($id);
        $msg    = "";
        if (!$user) {
            $alert = "sukses";
            $msg .= "User was not found";
        }

        if ($this->request->isPost()) {

            $user->assign([
                'name' => $this->request->getPost('name', 'striptags'),
                'profilesId' => $this->request->getPost('profile', 'int'),
                'email' => $this->request->getPost('email', 'email'),
                'banned' => $this->request->getPost('banned'),
                'suspended' => $this->request->getPost('suspended'),
                'active' => $this->request->getPost('active')
            ]);
            
            if (!$user->save()) {
                $alert = "error";
                foreach($user->getMessages() as $message)
                {
                    $msg .= $message ." ";
                }
            } else {
                $alert = "sukses";
                $msg .= "User was updated successfully";
            }
        }

        $response = new \Phalcon\Http\Response();
        $response->setContentType('application/json', 'UTF-8');
        $response->setJsonContent(array('_id' => $this->request->getPost("name"),'alert' => $alert, 'msg' => $msg ));
        return $response->send();
    }