ed0522 Posted January 2, 2016 Share Posted January 2, 2016 <input type="hidden" name="skills[]" class="form-control" value="职称" id="usr"> Why prestashop can't get value of skills[] with $skills=Tools::getValue('skills');? I have tested it in smarty environment, it worked. But when I copy to prestashop and revise the code, it doesn't work? What's wrong with that? Could anyone help me? Link to comment Share on other sites More sharing options...
Diurne Posted January 4, 2016 Share Posted January 4, 2016 You're using it in a form tag ? if(Tools::isSubmit('nameofsubmitbutton')) In the worst case use the $_POST["skills"]; you should get what you want only if the input wanted are in a form. <form method="post"> </form> Link to comment Share on other sites More sharing options...
vekia Posted January 4, 2016 Share Posted January 4, 2016 what you see if you will use |var_dump modifier on this variable? Link to comment Share on other sites More sharing options...
ed0522 Posted January 5, 2016 Author Share Posted January 5, 2016 it shows NULL. Link to comment Share on other sites More sharing options...
ed0522 Posted January 5, 2016 Author Share Posted January 5, 2016 (edited) Yes, I used the form label. The database shows "false", which means it saved nothing. I also tried the $_POST[], but the result is the same. The code worked well outside the prestashop. Edited January 5, 2016 by ed0522 (see edit history) Link to comment Share on other sites More sharing options...
ed0522 Posted January 5, 2016 Author Share Posted January 5, 2016 (edited) <form method="post" action="http://localhost/prestashop/en/index.php?fc=module&module=myregister&controller=cregisterProcess"> <div class="form-group"> <label for="name"><p style="color:#6E6E6E;">资格证书(点击添加)</p></label><br> <button type="button" onclick="addRow(this)" value=0 readonly="readonly" class="btn btn-info">外语</button> <button type="button" onclick="addRow(this)" value=1 readonly="readonly" class="btn btn-info">计算机</button> <button type="button" onclick="addRow(this)" value=2 readonly="readonly" class="btn btn-info">会计</button> <button type="button" onclick="addRow(this)" value=3 readonly="readonly" class="btn btn-info">职称</button> <button type="button" onclick="addRow(this)" value=4 readonly="readonly" class="btn btn-info">其他</button> </div> <table class="table table-bordered" id="skillsTable"> <thead> <tr> <th>技能</th> <th>分类</th> <th>资格考试</th> <th>分数/等级</th> <th>删除</th> </tr> <tr> <td>例:外语</td> <td>日语</td> <td>N1</td> <td>125</td> <td><button type="button" class="btn btn-default">删除</button></td> </tr> </thead> {for $i=1 to $rowNumbers} <tr> <td><input type="hidden" name="skills[]" class="form-control"readonly="readonly" value="{$skills[$i*4-4]}" id="usr">{$skills[$i*4-4]}</td> <td><input type="text" name="skills[]" class="form-control" value="{$skills[$i*4-3]}" id="usr"></td> <td><input type="text" name="skills[]" class="form-control" value="{$skills[$i*4-2]}" id="usr"></td> <td><input type="text" name="skills[]" class="form-control" value="{$skills[$i*4-1]}" id="usr"></td> <td><button type="button" onclick="delRow(this)" class="btn btn-default">删除</button></td> </tr> {/for} </table> JS: <SCRIPT> function addRow(button) { //Add row var addrow=skillsTable.insertRow(-1); var addCell01=addrow.insertCell(0); var addCell02=addrow.insertCell(1); var addCell03=addrow.insertCell(2); var addCell04=addrow.insertCell(3); var addCell05=addrow.insertCell(4); //Get events and info var bottonValue=button.value; if(bottonValue==0){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="外语" id="usr">外语'; }else if(bottonValue==1){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="计算机" id="usr">计算机'; }else if(bottonValue==2){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="会计" id="usr">会计'; }else if(bottonValue==3){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="职称" id="usr">职称'; }else if(bottonValue==4){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="其他" id="usr">其他'; } // Add values to the new cells: addCell02.innerHTML = '<input type="text" name="skills[]" class="form-control" id="usr">'; addCell03.innerHTML = '<input type="text" name="skills[]" class="form-control" id="usr">'; addCell04.innerHTML = '<input type="text" name="skills[]" class="form-control" id="usr">'; addCell05.innerHTML = '<button type="button" onclick="delRow(this)" class="btn btn-default">删除</button>'; } function delRow(rowNum) { var skillsTable=document.getElementById("skillsTable"); var rowNumber=rowNum.parentNode.parentNode.rowIndex; skillsTable.deleteRow(rowNumber); } </SCRIPT> PHP function: //getSkills $skills=Tools::getValue('skills'); var_dump($skills); Edited January 5, 2016 by ed0522 (see edit history) Link to comment Share on other sites More sharing options...
ed0522 Posted January 5, 2016 Author Share Posted January 5, 2016 Click a button, it will add a row with 4 input fields in the table. When I save it, it will show the table I submitted. Link to comment Share on other sites More sharing options...
Diurne Posted January 5, 2016 Share Posted January 5, 2016 Try out without the action : action="http://localhost/pre...registerProcess" <form method="post"> </form> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now