示例#1
0
    public function start_control($compiler, $node)
    {
        echo "<?";
        ?>
		if(!($_formControlModel->modelCache->hasField('<?php 
        echo $node->getAttribute("name");
        ?>
'))) {
			echo '<div class="mvcControlWarning" style="color: red">Warning, model ' . $_formControlModel->modelName . ' has no member ' .
					'named <?php 
        echo $node->getAttribute("name");
        ?>
</div>';
		}
		<?php 
        echo "?>";
        /*
         * If the node has children, then we assume that a label is also defined in the tag and we create the div and all. 
         * If not, we create just the input -elemnt
         */
        if ($node->hasChildNodes()) {
            echo $this->html->element("div", $this->html->element("label", ViewCompiler::collect($node), array("for" => $node->getAttribute("name"))) . $this->generateErrorCode($node->getAttribute("name")) . $this->html->element("input", null, ViewCompiler::attributesAsArray($node->attributes)), array("class" => "mvcInput", "id" => "inputFld" . $node->getAttribute("name")));
        } else {
            echo $this->html->element("input", null, ViewCompiler::attributesAsArray($node->attributes));
        }
        return false;
    }
示例#2
0
    public function start_control($compiler, $node)
    {
        echo "<?\n";
        ?>
		$_formControlModel = Model::getModel('<?php 
        echo $node->getAttribute("model");
        ?>
');
		if(!isset($MVC_CURRENT_MODEL)) {
			$MVC_CURRENT_MODEL = $_formControlModel;
		}
		<?php 
        echo "\n?>";
        $parameters = ViewCompiler::attributesAsArray($node->attributes);
        /*
         * See if we need to automatically create a controller for this save action
         */
        if ($node->getAttribute("autocreate-controller") == "true") {
            $target = ControllerGenerator::generateSaveController($compiler->controller, $compiler->method, $node->getAttribute("model"), $node->getAttribute("redirect"));
            $parameters["method"] = "post";
            $parameters["action"] = $target;
        }
        unset($parameters["model"]);
        unset($parameters["redirect"]);
        unset($parameters["autocreate-controller"]);
        echo $this->html->startElement("form", $parameters);
        return true;
    }