Skip to content

Loading…

Couple of upgrades #3

Open
wants to merge 4 commits into from

2 participants

@juzna

Hope that you will like some of them :)

@tenerd

cau, ten opraveny setValue bych tam nedaval dokud nebude primo v nette prijmut ten pozadovany pull request.

@juzna

tak pockame, snad to davidek brzo zapracuje

@juzna

Tak v Nette uz to je mergnute, tak muzeme mergovat i tady ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 36 additions and 1 deletion.
  1. +2 −0 DynamicContainer.php
  2. +17 −0 DynamicContainerCore.php
  3. +17 −1 FormMacros.php
View
2 DynamicContainer.php
@@ -151,6 +151,8 @@ protected function createRow($name = null) {
if ($this->useAjax)
$button->getControlPrototype()->class($this->ajaxClass);
}
+
+ return $innerContainer;
}
/**
View
17 DynamicContainerCore.php
@@ -270,6 +270,23 @@ protected function fireOnChange() {
// </editor-fold>
+
+ /**
+ * Override: set values for this container while adding rows for it
+ * (needs https://github.com/nette/nette/pull/217 implemented in Nette)
+ *
+ * @param array $values
+ * @param bool $erase
+ * @return void
+ */
+ public function setValues($values, $erase = FALSE) {
+ $this->clearRows();
+ foreach($values as $key => $sub) {
+ $this->createRow($key)->setValues($sub, $erase);
+ }
+ }
+
+
// <editor-fold defaultstate="collapsed" desc="register helpers">
public static function FormContainer_addDynamicContainerCore(FormContainer $_this, $name = null, $factoryCallback = null) {
View
18 FormMacros.php
@@ -129,6 +129,17 @@ public static function input($name, $modifiers) {
echo $input;
}
+ public static function macroPair($content) {
+ list($name, $modifiers) = self::fetchNameAndModifiers($content);
+ return "Addons\Forms\FormMacros::pair($name, $modifiers)";
+ }
+ public static function pair($name, $modifiers) {
+ $control = self::getControl($name);
+ echo self::getForm()->getRenderer()->renderPair($control);
+ }
+
+
+
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="{label}">
@@ -162,7 +173,11 @@ public static function inputValue($name, $modifiers = array()) {
public static function macroBeginDynamicContainer($content) {
list($name) = self::fetchNameAndModifiers($content);
- return '$dynamicContainers = Addons\Forms\FormMacros::getControl('.$name.')->getComponents(); Addons\Forms\FormMacros::beginContainer('.$name.'); foreach($dynamicContainers as $dynamicContainerName => $dynamicContainer): Addons\Forms\FormMacros::beginContainer($dynamicContainerName);';
+ return
+ '$dynamicContainers = Addons\Forms\FormMacros::getControl('.$name.')->getComponents();
+ Addons\Forms\FormMacros::beginContainer('.$name.');
+ foreach($dynamicContainers as $dynamicContainerName => $dynamicContainer):
+ Addons\Forms\FormMacros::beginContainer($dynamicContainerName);';
}
public static function macroEndDynamicContainer($content) {
return "Addons\Forms\FormMacros::endContainer(); endforeach; Addons\Forms\FormMacros::endContainer();";
@@ -178,6 +193,7 @@ public static function register() {
LatteMacros::$defaultMacros["formErrors"] = '<?php %Addons\Forms\FormMacros::macroFormErrors% ?>';
+ LatteMacros::$defaultMacros["pair"] = '<?php %Addons\Forms\FormMacros::macroPair% ?>';
LatteMacros::$defaultMacros["input"] = '<?php %Addons\Forms\FormMacros::macroInput% ?>';
LatteMacros::$defaultMacros["label"] = '<?php %Addons\Forms\FormMacros::macroLabel% ?>';
LatteMacros::$defaultMacros["inputValue"] = '<?php %Addons\Forms\FormMacros::macroInputValue% ?>';
Something went wrong with that request. Please try again.