2017-09-23 48 views
0

我已經實現了一個表單來註冊用戶的電子郵件,所以我們可以發送給他們更新。Grav表格插件錯誤

該表單完美地整合,但沒有理由失敗的生產。

當我試圖發送郵件,我收到了500後的錯誤有以下信息:生成表單

{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" 

代碼:

{% 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> 

我做了檢查權限和明確的緩存,而不成功,我沒有想法。

謝謝。

回答

0

看起來您的複選框有問題。

你能發表你的表單定義嗎?

+0

我沒有任何複選框!我添加生成表單的代碼。 – mhlsf

2

文件/user/plugins/form/classes/form.php在行552包含這行代碼if ($field['type'] == 'checkbox') {這意味着:如果字段的類型是「複選框」然後...

你的錯誤「未定義索引:類型」(其被stricly相關陣列)聲明他無法在$field數組中找到並索引名爲'type'的數據。

這段代碼(第552行)也在一個名爲post()的函數中執行。

所以,我可以推論:在發佈請求後檢查您的字段,其中一個沒有type屬性。

爲了解決這個問題,你可以檢查你生成的HTML輸出(檢查元素)在窗體上,並找到錯誤的格式化輸入。