I implemented "Formmail validated by HTML" for pico 1.50
You may ask "What is new?"
OK.
This system uses Template data written by HTML designer as "Validator".
You need not XML definition etc.
And I don't value the module like liaise or class of XoopsForm, because such HTML generating system kills the liberty for HTML design.
I believe this system makes both designers and programmers happy.
Anyway try to make a contents like this.
Filters: Turn 'Smarty(XoopsTpl)' on.
All of the rest options should be turned off.
(Also "body cache")
<{capture}>
<form>
<label for="yourname">Your Name</label>
<input type="text" name="yourname" id="yourname" class="required" />
<br />
Fruit:
<label for="checkbox_orange">orange</label>
<input type="checkbox" name="favorite_fruit[]" id="checkbox_orange" class="required" value="orange" />
<label for="checkbox_apple">apple</label>
<input type="checkbox" name="favorite_fruit[]" id="checkbox_apple" class="required" value="apple" />
<label for="checkbox_pear">pear</label>
<input type="checkbox" name="favorite_fruit[]" id="checkbox_pear" class="required" value="pear" checked="checked" />
<br />
<label for="youremail">email</label>
<input type="text" name="youremail" id="youremail" class="email" />
<br />
<label for="selbox">Select Box</label>
<select name="selbox" id="selbox" class="required">
<option value="">-- select it --</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>
</select>
<br />
<label for="content">Content</label>
<textarea name="content" id="body"></textarea>
<br />
<input type="submit" value="Confirm" />
</form>
<{/capture}>
<{formmail}>
if( strstr( $fieldsetblock , $tag ) && preg_match( '#<legend[^>]*>([^<]+)</legend>#' , $fieldsetblock , $sub_regs ) ) {
if( strstr( $fieldsetblock , $tag ) && preg_match( '#<legend[^>]*>(.+)</legend>#' , $fieldsetblock , $sub_regs ) ) {
ここ、私は否定先読みを使ってとやってました。一応これで上手くいくかと思います。if( preg_match( '#<fieldset(?:(?!fieldset).)*'.preg_quote($tag).'.*</fieldset>#isU' , $form_html , $regs ) ) {
実は1.60くらいでバグかな?と思っていたのですが、なんやかんやで先送りになってました。その時点でご報告していればよかったですね・・・
<fieldset>と<legend>の間に</fieldset>が見つかったら終了、って正規表現がパッと書けなかったので、preg_split()でいったん分割しました。
if( preg_match( '#<fieldset(?:(?!fieldset).)*'.preg_quote($tag).'.*</fieldset>#isU' , $form_html , $regs ) ) {
GIJOE wrotes:
<fieldset>と<legend>の間に</fieldset>が見つかったら終了、って正規表現がパッと書けなかったので、preg_split()でいったん分割しました。
1.75aを試してみてください。
# いただいたコードが悪いってことはないのですが、<fieldset>のブロックという概念から外れてしまうので。
jidaikobo wrotes:
pico の survey プラグインで遊ぼう!の picoSurveyAssistant を書いていて気づいたんですが、pico の formmail プラグインで、checkbox や radio が複数あるフォームの場合、最初の要素の legend が、以降すべての checkbox と radio のタイトルとして、メールで送られているようでした。
// search the nearest <regend> for radio/checkbox
if( preg_match( '#<fieldset.*'.preg_quote($tag).'.*</fieldset>#isU' , $form_html , $regs ) ) {
if( preg_match( '#<legend[^>]*>([^<]+)</legend>#' , $regs[0] , $sub_regs ) ) {
$label = strip_tags( @$sub_regs[1] ) ;
}
}
// search the nearest <legend> for radio/checkbox
if( preg_match( '#<fieldset.*'.preg_quote($tag).'.*</fieldset>#isU' , $form_html , $regs ) ) {
if( preg_match_all( '#<legend[^>]*>([^<]+)</legend>#' , $regs[0] , $sub_regs ) ) {
$sub_regs_tmp = isset( $sub_regs[1] ) ? array_pop( $sub_regs[1] ) : '' ;
$label = strip_tags( $sub_regs_tmp ) ;
}
}
I hope to read more about this new feature and
possibilities to replace liaise or formulize.