macro NormalInput issue

  • Nowadays making a big project using an asgard, and today i found one thing which Im not sure about.
    In macro, there is a function normalInput. It creates label and input. Today i was trying to make an input and whatever i was doing it was not showing the value in edit form. Then i looked at code:

    if (is_object($object)) {
        $currentData = $object->{$name} ?: '';
    } else {
        $currentData = '';

    And as far as i understand it will show the data only for objects, but im not so good in programming as u guys. So just wondering. Should this code be like that...

  • Global Moderator

    Well should/could depends on who makes macro and for what purpose.
    You could pass all required data or you could manually make form or you could ultimately create your own macros.

    I think the macros are just fine, though i personally do not use them in Asgard.

    But it's pretty straight forward you do validation on data and if it fails you return no entity object so it will display data you supplied to the form.
    Of course if you load up edit view you would want to create empty ViewErrorBag to satisfy macro requirements and supply your model data.

    public function edit(MyModel $mymodel) {
        $errors = new \Illuminate\Support\ViewErrorBag;
        $mymodelData = $mymodel->get(1);
        return view('module::admin.entity.edit', compact('errors', 'mymodelData'));
    // So later in view you could use macro
    // Form::NormalInput('farmerName', 'Jogh Farmer', $errors, $mymodelData)

Log in to reply

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.