Jump to content
php.lv forumi

$element->input custom


anonīms

Recommended Posts

Veidoju pats savu f-ju jau esošajai lapai, lai ievērojami atvieglotu gan validāciju, gan formu izveidi.

http://paste.php.lv/...c9ee87?lang=php

Itkā viss strādā kā vajag, tikai izdomāju, ka vajag permissions nevis kā katru ar savu nosaukumu, bet zem kopējā "taga" perm

 

Tātad name="perm[x]"

 

Problēma ir pie submit pogas nospiešanas. Kā panākt, lai pēc submit, ja čekbox ir ieķeksēts, tad arī formā tas būtu. Respektīvi 33-36 rindiņa. Paldies un ceru uz ātru atbildi.

 

EDIT: un views

 

  	<strong><?php print _('Users'); ?></strong>
  	<table><tr>
  	<td><?php print $element->input('perm[b]','checkbox',false,$group->permissions['b']); ?> <?php print _('ban/block'); ?></td>
  	<td><?php print $element->input('perm[1]','checkbox',false,$group->permissions['1']); ?> <?php print _('coins'); ?></td>
  	<td><?php print $element->input('perm[u]','checkbox',false,$group->permissions['u']); ?> <?php print _('edit'); ?></td>
  	</tr></table>

Edited by anonīms
Link to comment
Share on other sites

Šķiet, ka pats tiku galā. Nezinu cik gudri vai veiksmīgi tas ir, bet strādāt, strādā.

 

  // set values
 if(isset($_POST[$name]) AND $_POST[$name] AND !is_array($_POST[$name])) {
  $value = strip_tags($_POST[$name]);

  }
  else { //array :: name[subname]

 // get post name
 $array_name = explode('[',$name); //perm
 $array_name2 = substr($array_name[1],0,-1); // u

 if($_POST[$array_name[0]][$array_name2]) {
  $value = 'on';
 }
  }

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...