public function generateForm(Items\Base $item, Nette\Forms\Container &$formContainer, $name, $parentName, $togglingObject, array $userOptions = []) { $input = $formContainer->addCheckbox($name, $name); $input->setOption('id', $parentName . '__' . $name); $input->setValue($item->getContent()); if (!is_null($togglingObject)) { $togglingObject->toggle($input->getOption('id')); } $item->applyUserOptions($input, $userOptions); }
protected function createImageUpload(Nette\Forms\Container $container, $image) { $id = $this->lookupPath('Nette\\Application\\UI\\Presenter') . '-form'; if ($image !== NULL) { $container->addCheckbox('deleteImg', 'common.form.removeImage')->addCondition(Form::EQUAL, FALSE)->toggle($id . '-pic-customize'); } $container->addFileUpload('img', 'common.form.image')->setOption('id', $id . '-pic-image')->addCondition(Form::FILLED)->addRule(Form::IMAGE); // upload is filled => show img options $container['img']->addCondition(Form::FILLED)->toggle($id . '-pic-customize'); // has image and deleteImg is checked => show upload if ($image !== NULL) { $container['deleteImg']->addCondition(Form::EQUAL, TRUE)->toggle($id . '-pic-image'); } }
/** * @param \Nette\Forms\Container $container * @throws Exception * @internal */ public function addCheckers(\Nette\Forms\Container $container) { $items = $this->grid->getData(); $primaryKey = $this->getPrimaryKey(); foreach ($items as $item) { try { $primaryValue = $this->grid->getProperty($item, $primaryKey); if (!isset($container[$primaryValue])) { $container->addCheckbox(Helpers::formatColumnName($primaryValue))->controlPrototype->title = $primaryValue; } } catch (\Exception $e) { throw new Exception('You should define some else primary key via $grid->setPrimaryKey() ' . "because currently defined '{$primaryKey}' key is not suitable for operation feature."); } } }
/** * @param \Nette\Forms\Container $container * @internal */ public function addCheckers(\Nette\Forms\Container $container) { $items = $this->grid->getData(); $primaryKey = $this->getPrimaryKey(); $propertyAccessor = $this->grid->getPropertyAccessor(); foreach ($items as $item) { $primaryValue = $propertyAccessor->getProperty($item, $primaryKey); if (!isset($container[$primaryValue])) { $container->addCheckbox(Helpers::formatColumnName($primaryValue)); } } }