Let authenticated users enter stream entries in frontend
Created 7 years ago by keevitaja

Hello PyroMans!

I am tasked to create a classified portal, where people can register and add the classified adds. I successfully created the addon with 2 streams: items and categories. So admin can mess with the classified adds. But how do i enable users to create them in the frontend side?

ryanthompson  —  7 years ago

So for this - you will want to use the form plugin. Consider the one I am making literally right now (it is incomplete but good example):

{{ form('streams', 'contact_requests') }} // Auto generate the form

I typically do something like this:

{% set form = form('streams', 'contact_requests') %}

{{ form.open|raw }}
<div class="container-fluid">

    <div class="row">
        <div class="col-lg-5">
            {{ form.fields.first_name|raw }}
        </div>
        <div class="col-lg-7">
            {{ form.fields.last_name|raw }}
        </div>
    </div>

    <div class="row">
        <div class="col-lg-5">
            {{ form.fields.email_address|raw }}
        </div>
        <div class="col-lg-7">
            {{ form.fields.phone_number|raw }}
        </div>
    </div>

    {{ form.actions|raw }}

</div>
{{ form.close|raw }}
keevitaja  —  7 years ago

This is throwing an error:

FatalErrorException in Environment.php(403) : eval()'d code line 0:
Method Anomaly\Streams\Platform\Ui\Form\FormCriteria::__toString() must not throw an exception, caught ErrorException: Invalid argument supplied for foreach()
{% set form = form('classifieds', 'items') %}

{{ form.open|raw }}

{{ form.actions|raw }}
{{ form.close|raw }}

I also tried

{% set form = form('streams', 'classifieds_items') %}
Method Anomaly\Streams\Platform\Ui\Form\FormCriteria::__toString() must not throw an exception, caught ErrorException: Invalid argument supplied for foreach()