4

I want to call a component inside a component with a variable, like this:enter image description here

Here's the code of the default.html->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<div class="container">
    <div class="row">
        {% partial __SELF__ ~ "::category" category=__SELF__.category childscategory=__SELF__.childscategory%}
        <div class="col-xs-3">
          <strong>DATA</strong>
          <ul class="list-group text-center">
            {% partial __SELF__ ~ "::dates" files=__SELF__.files  %}
          </ul>
        </div>

        <div class="col-xs-3">
          <strong>Nome do Ficheiro</strong>
          <ul class="list-group text-center">
            {% partial __SELF__ ~ "::files" files=__SELF__.files  %}
          </ul>
        </div>

        <div class="col-xs-3">
          <strong>Descrição</strong>
          <ul class="list-group text-center">
            {% partial __SELF__ ~ "::description" files=__SELF__.files %}
          </ul>
        </div>

        <div class="col-xs-1">
          <strong>{{__SELF__.labelpresentation}}</strong>
          <ul class="list-group text-center">
            {% partial __SELF__ ~ "::download_1" files=__SELF__.files %}
          </ul>
        </div>
          -> I WANT TO CALL THE COMPONENT HERE <-
    </div>
</div>

If you want me to post more code like the .php, it's ok

Ricardo Cruz
  • 117
  • 10
  • 2
    Don't be lazy, post real code snippets instead of screenshots, this can help others by reusing your code to answer your question. – Stacked Jun 16 '16 at 10:01

1 Answers1

5

Example: use the fileUploader component in my ApplicationForm component. In ApplicationForm class, add this:

public function init()
{
    $component = $this->addComponent(
        'Responsiv\Uploader\Components\FileUploader',
        'fileUploader',
        [
            'deferredBinding'   => true,
            'maxSize'           => $this->property('maxFileSize'),
            'fileTypes'         => $this->property('fileTypes'),
            'placeholderText'   => $this->property('placeholderText'),
        ]
    );

    $component->bindModel('cv', new Application());
}

And in the view (default.htm) of the ApplicationForm component use the initialized component like so:

{% component 'fileUploader' %}
Ametad
  • 402
  • 2
  • 10
  • The `$component->bindModel('cv', new Application());` part is produced a Class not found error for me. Omitting it worked fine. – Mike Jan 09 '19 at 22:12