0

I have implemented a form to register email of user so we can send them update.

The form works perfectly on integration but without reason fails in production.

When I tried to send the message I get a 500 post error with the following informations :

{error: {type: "Whoops\Exception\ErrorException", message: "Undefined index: type",…}}
error : {type: "Whoops\Exception\ErrorException", message: "Undefined index: type" , …}
file : "/var/www/20170803_project/user/plugins/form/classes/form.php"
line : 552
message : "Undefined index: type"
type : "Whoops\Exception\ErrorException"

Code that generate the form:

{% set scope = scope ?: 'data.' %}
{% set multipart = '' %}
{% set method = form.method|upper|default('POST') %}

{% set action = form.action ? base_url ~ form.action : base_url ~ page.route 
 ~ uri.params %}

{% if (action == base_url_relative) %}
{% set action = base_url_relative ~ '/' ~ page.slug %}
{% endif %}

<form name="{{ form.name }}"
  action="{{ action }}"
  method="{{ method }}"{{ multipart }}
  {% if form.id %}id="{{ form.id }}"{% endif %}
  {% block form_classes %}
  {% if form.classes %}class="{{ form.classes }}"{% endif %}
  {% endblock %}
>

<div class="stay_tune pure-u-4-5 pure-g">
{% block inner_markup_fields_start %}{% endblock %}

<div class="group pure-u-3-5 email_register_container">
  <input name="email" type="email" required>
  <span class="highlight"></span>
  <span class="bar"></span>
  <label class="label">Email</label>
</div>

{% include "forms/fields/formname/formname.html.twig" %}

{% block inner_markup_fields_end %}{% endblock %}

{% block inner_markup_buttons_start %}
<div class="pure-u-2-5 register_button_container">
{% endblock %}
{{dump(form)}}
  <p class="message_form">{{form.process[1].message}}</p>
  <button type="submit" class="register_button" name="button">
{{form.button.value}}</button>
{% block inner_markup_buttons_end %}
</div>
{% endblock %}
</div>

{{ nonce_field('form', 'form-nonce')|raw }}
</form>

I did check permission and clear cache without sucess, I'm out of ideas.

Thank you.

mhlsf
  • 303
  • 4
  • 14

2 Answers2

2

The file /user/plugins/form/classes/form.php at line 552 contains this line of code if ($field['type'] == 'checkbox') { which means: if the field type is 'checkbox' then...

Your error "Undefined index: type" (which is stricly correlated to arrays) states that he cannot find and index named 'type' in $field array.

This piece of code (line 552) is also executed in a function called post().

So, I can deduce that: while checking your fields after the post request one of them doesn't have the type property.

To solve the problem you could check your generated HTML output (inspect element) on the form and find the wrong formatted input.

Mavin
  • 64
  • 4
0

it seems like there is a problem with your checkbox.

Can you post your form definition?

Paul Massendari
  • 417
  • 3
  • 6