placeholder dans les input en boucle

  • Posts: 2639
  • Thank you received: 66
  • Hikashop Business
10 years 6 months ago #149602

-- HikaShop version -- : 230

je veux mettre un placeholder dans les input de type text et texarea

à quelle endroit je met ca avec la valeur du label ?

$this->fieldsClass->display(
						$oneExtraField,
						@$this->$type->$fieldName,
						'data['.$type.']['.$fieldName.']',
						false,
						' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\''.$type.'\',0);"',
						false,
						$this->extraFields[$type],
						$this->$type
				);

merci

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 6 months ago #149652

Bonjour,

Il faut faire une modification tel que:

<div id="hikashop_product_custom_item_info" class="hikashop_product_custom_item_info">
	<table width="100%">
	<?php
	foreach ($this->itemFields as $fieldName => $oneExtraField) {
		$placeHolder = '';
		if($oneExtraField->field_type == 'text' || $oneExtraField->field_type == 'textarea')
			$placeHolder = 'placeholder="default value"';

		$itemData = JRequest :: getString('item_data_' . $fieldName, $this->element-> $fieldName);
		?>
		<tr id="hikashop_item_<?php echo $oneExtraField->field_namekey; ?>" class="hikashop_item_<?php echo $oneExtraField->field_namekey;?>_line">
			<td class="key">
				<span id="hikashop_product_custom_item_name_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_item_name">
					<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
				</span>
			</td>
			<td>
				<span id="hikashop_product_custom_item_value_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_item_value"><?php
					$onWhat='onchange';
					if($oneExtraField->field_type=='radio')
						$onWhat='onclick';
					$oneExtraField->product_id = $this->element->product_id;
					echo $this->fieldsClass->display($oneExtraField,$itemData,'data[item]['.$oneExtraField->field_namekey.']',false,' '.$placeHolder.' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'item\',0);"');
				?></span>
			</td>
		</tr>
	<?php
	}
	?>
	</table>
</div>

The following user(s) said Thank You: erickb

Please Log in or Create an account to join the conversation.

  • Posts: 2639
  • Thank you received: 66
  • Hikashop Business
10 years 6 months ago #149653

je vais regarder tout ça

merci

Please Log in or Create an account to join the conversation.

  • Posts: 2639
  • Thank you received: 66
  • Hikashop Business
10 years 6 months ago #149667

comment ajoutez vous une class aux input ?

je veux ajouter la class required

$requis = '';	
	$required = $oneExtraField->field_required;
		if($required == 1){
			$requis = ' required';
		}


echo $this->fieldsClass->display(
						$oneExtraField,
						$this->$type->$fieldName,
						'data['.$type.']['.$fieldName.']',
						false,' '.$placeHolder.
						''.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\''.$type.'\',0);"',
						false,
						$this->extraFields[$type],
						$this->$type
				);

et comment supprimer dans la boucle les <span class="hikashop_field_required">*</span>


merci

Last edit: 10 years 6 months ago by erickb.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 6 months ago #149672

Cela fonctionne, testé en local. Editez vous bien la vue "product / show_block_custom_item" ?

<div id="hikashop_product_custom_item_info" class="hikashop_product_custom_item_info">
	<table width="100%">
	<?php
	foreach ($this->itemFields as $fieldName => $oneExtraField) {
		$placeHolder = '';
		if($oneExtraField->field_type == 'text' || $oneExtraField->field_type == 'textarea')
			$placeHolder = 'placeholder="'.$oneExtraField->field_realname.'"';

		$itemData = JRequest :: getString('item_data_' . $fieldName, $this->element-> $fieldName);
		?>
		<tr id="hikashop_item_<?php echo $oneExtraField->field_namekey; ?>" class="hikashop_item_<?php echo $oneExtraField->field_namekey;?>_line">
			<td class="key">
				<span id="hikashop_product_custom_item_name_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_item_name">
					<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
				</span>
			</td>
			<td>
				<span id="hikashop_product_custom_item_value_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_item_value"><?php
					$onWhat='onchange';
					if($oneExtraField->field_type=='radio')
						$onWhat='onclick';
					$oneExtraField->product_id = $this->element->product_id;
					echo $this->fieldsClass->display($oneExtraField,$itemData,'data[item]['.$oneExtraField->field_namekey.']',false,' '.$placeHolder.' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'item\',0);"');
				?></span>
			</td>
		</tr>
	<?php
	}
	?>
	</table>
</div>

Please Log in or Create an account to join the conversation.

  • Posts: 2639
  • Thank you received: 66
  • Hikashop Business
10 years 6 months ago #149749

oui ca marche mais ma deuxième question :
comment virer ce span avec * (voir ma question ci dessus)
et ajouter un class="required" à la place ?

tel quel c'est très dur de garder un code souple et coherent , tout est génère en amont et le html + css est dur ou impossible à changer

merci

Last edit: 10 years 6 months ago by erickb.

Please Log in or Create an account to join the conversation.

  • Posts: 82567
  • Thank you received: 13289
  • MODERATOR
10 years 6 months ago #149821

Il n'y a jamais rien d'impossible à changer en programmation. Ca peut en effet être compliqué dans certains cas. Mais ici, rien de très compliqué.
Vous pourriez faire par exemple comme cela:

echo sre_replace('<span class="hikashop_field_required">*</span>','',$this->fieldsClass->display($oneExtraField,$itemData,'data[item]['.$oneExtraField->field_namekey.']',false,' class="required" '.$placeHolder.' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\'item\',0);"'));

Please Log in or Create an account to join the conversation.

  • Posts: 2639
  • Thank you received: 66
  • Hikashop Business
10 years 6 months ago #149847

Je peux bien sur tout re-ecrire mais je parlais de l'insertion dans votre boucle

merci pour l'info

sinon dans une version future un placeholder en natif yes/no serait vraiment un plus pour les petits écran et versions mobiles

Please Log in or Create an account to join the conversation.

Time to create page: 0.076 seconds
Powered by Kunena Forum