我有一个PHP + HTML代码生成一个联系人表单:
public function doContactForm() {
ob_start();
$current_user = wp_get_current_user();
?>
<div id="vue_contact_form_app">
<div class="basic-message" v-bind:class="{ 'error-message' : status == 'error', 'success-message' : status == 'sent' || status == 'sending' }" v-on:click="closeMessage">
<p v-show="status != 'clean'">{{ actionMessage }}</p>
</div>
<form class="vue-form" @submit.prevent="submit">
<fieldset>
<div>
<label class="label" for="name">Your Name:</label>
<input type="text" name="name" id="name" placeholder="Your Name" required="" maxlength="80" v-model="name">
</div>
<div>
<label class="label" for="email">Your Email:</label>
<input type="email" name="email" id="email" placeholder="name@domain.com" required="" maxlength="40" :class="{ email , error: !email.valid }" v-model="email.value">
</div>
<div>
<label class="label" for="subject">Subject:</label>
<input type="text" name="subject" id="subject" placeholder="An iteresting idea." required="" maxlength="120" v-model="subject">
</div>
<div>
<label class="label" for="textarea">Message:</label>
<textarea class="message" name="textarea" id="textarea" placeholder="Dear Mr. Dmitry, ..." required="" v-model="message.text" :maxlength="message.maxlength"></textarea>
<span class="counter">{{ message.text.length }} / {{ message.maxlength }}</span>
</div>
<div class="g-recaptcha" data-sitekey="<?php echo $this->getOption('PublicKey');?>"></div>
<div>
<input type="submit" value="Send">
</div>
</fieldset>
</form>
</div>
字符串
如果设置了$current_user
,如何用$current_user->user_email
初始化Your Name
字段?应该分配什么属性,语法是什么?
1条答案
按热度按时间igetnqfo1#
我假设你指的是文本框而不是标签,因为标签没有值。
您可以将数据注入到HTML
input
元素的value
属性中,但首先要测试(使用三元运算符)对象是否已设置。字符串