2

I'm trying to get the _POST data for my form in a plugin, and for whatever reason am unable to get the selected option from a select tag:

 <form class="parseResults" action="actions/MyPlugin/myFunctionAjax" method="post" name="submitResults">
    <select name="submission">
        <option value="view">View</option>
        <option value="submit">Submit</option>
    </select>
    <textarea rows="9" cols="80" name="content"></textarea>
    <input type="submit" value="Submit" name="submit">
</form>

And then in my plugin, I can get the textarea form content like:

    $formContent = craft()->request->getPost('content');

But when I try to get the selected option from the #submission select, nothing returns

    $submissionType = craft()->request->getPost('submission');

What am I missing or doing wrong in order to get the selected option?

  • In CraftCMS, is there a folder named 'actions'? I was thinking that the requirement is to have the folder named 'plugins'? Thanks. – buck1112 Jun 28 '18 at 20:22
2

Form elements need to have a name attribute.

<select name="submission" id="submission">
<option value="view">View</option>
<option value="submit">Submit</option>
</select>

<textarea name="content" rows="9" cols="80" id="content"></textarea>

That should do the trick!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.