0
我創建一個函數內的URL,hook_form_alter的實施方案內用來添加一個新的按鈕(我試圖解決這個問題:Drupal - Creating 'add another' buttons on node edit forms that will retain node relationships):在URL允許保留字符
的相關部分hook_form_alter:
if ($form_id === 'image_node_form') {
$form['buttons']['submit_again'] = array(
'#type' => 'submit',
'#value' => t('TEST'),
'#weight' => 41,
'#submit' => array('node_form_submit', 'add_another_node_form_submit'),
);
}
其使用功能:
function add_another_node_form_submit($form, &$form_state) {
$refnode = $form['field_gallery'][0]['nid']['#default_value'];
$refnode = 'node/add/image/'.$refnode.'?destination='.$_REQUEST['destination'];
unset($_REQUEST['destination'], $_REQUEST['edit']['destination']);
$form_state['redirect'] = $refnode;
}
的修飾的形式:
<form action="/node/add/image/189?destination=marketplace%252Fproperties%252Ftest" accept-charset="UTF-8" method="post" id="node-form" enctype="multipart/form-data">
<div>
<div class="node-form">
<div class="standard">
<input type="hidden" name="changed" id="edit-changed" value="" />
<input type="hidden" name="form_build_id" id="form-9869451ca1d3c9b91806442e39026622" value="form-9869451ca1d3c9b91806442e39026622" />
<input type="hidden" name="form_token" id="edit-image-node-form-form-token" value="5b0ddf4a6a9bc7f54a61c666230169bf" />
<input type="hidden" name="form_id" id="edit-image-node-form" value="image_node_form" />
<input type="hidden" name="flag_friend_control" id="edit-flag-friend-control" value="" />
<div class="form-item" id="edit-field-gallery-0-nid-wrapper">
<label for="edit-field-gallery-0-nid">Marketplace item: </label>
test
</div>
<div id="edit-field-image-0-ahah-wrapper"><div class="form-item" id="edit-field-image-0-upload-wrapper">
<label for="edit-field-image-0-upload">Image: <span class="form-required" title="This field is required.">*</span></label>
<div class="filefield-element clear-block"><div class="widget-edit"><input type="hidden" name="field_image[0][fid]" id="edit-field-image-0-fid" value="0" />
<input type="hidden" name="field_image[0][list]" id="edit-field-image-0-list" value="1" />
<div class="form-item" id="edit-field-image-0-upload-wrapper">
<div class="filefield-upload clear-block"><input type="file" name="files[field_image_0]" class="form-file" id="edit-field-image-0-upload" size="22" />
<input type="submit" name="op" id="edit-field-image-0-filefield-upload" value="Upload" class="form-submit" />
</div>
<div class="description">Maximum file size: <em>2 MB</em><br />Allowed extensions: <em>png gif jpg jpeg</em></div>
</div>
</div></div>
</div>
</div><div class="form-item" id="edit-title-wrapper">
<label for="edit-title">Caption: <span class="form-required" title="This field is required.">*</span></label>
<input type="text" maxlength="255" name="title" id="edit-title" size="60" value="" class="form-text required" />
</div>
<fieldset class=" collapsible collapsed"><legend>Comment settings</legend><div class="form-radios"><div class="form-item" id="edit-comment-0-wrapper">
<label class="option" for="edit-comment-0"><input type="radio" id="edit-comment-0" name="comment" value="0" checked="checked" class="form-radio" /> Disabled</label>
</div>
<div class="form-item" id="edit-comment-1-wrapper">
<label class="option" for="edit-comment-1"><input type="radio" id="edit-comment-1" name="comment" value="1" class="form-radio" /> Read only</label>
</div>
<div class="form-item" id="edit-comment-2-wrapper">
<label class="option" for="edit-comment-2"><input type="radio" id="edit-comment-2" name="comment" value="2" class="form-radio" /> Read/Write</label>
</div>
</div></fieldset>
</div>
<div class="admin">
<div class="authored">
</div>
<div class="options">
</div>
</div>
<input type="submit" name="op" id="edit-submit" value="Save" class="form-submit" />
<input type="submit" name="op" id="edit-preview" value="Preview" class="form-submit" />
<input type="submit" name="op" id="edit-submit-again" value="TEST" class="form-submit" />
</div>
</div></form>
在提交的URL顯示(例如):
/node/add/image/214%3Fdestination%3Dmarketplace%25252Fproperties%25252Ftest-0
如何停止保留字符 '?' '?destination'中的'='被轉換爲十六進制實體?
沒有進行HTML實體轉換。 – 2011-06-15 10:28:37
哪些角色在哪個點轉換?你能舉一個例子嗎? – 2011-06-15 10:29:50
嗯,我編輯了queston,希望它現在更清晰了...... – james6848 2011-06-15 10:48:01